package com.xwj.back.controller.user;

import com.xwj.back.pojo.User;
import com.xwj.back.service.user.PersonalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
public class PersonalController {

    @Autowired
    private PersonalService personalService;

    @GetMapping("/personal/get/byId/")
    public User getUserById(@RequestParam("id") Integer id){
        return personalService.getUserById(id);
    }

    //个人中心上传头像
    @GetMapping("/personal/update/avatar/")
    public Map<String,String> updateUserAvatar(@RequestParam("id") Integer id,@RequestParam("photo") String photo){
        Map<String, String> map = new HashMap<>();
        map.put("message",personalService.updateUserAvatar(id,photo));
        return map;
    }
    //个人中心修改个人资料
    @PostMapping("/personal/update/info/")
    public Map<String,String> updatePersonalInfo(@RequestBody Map<String,String> data){
        return personalService.updatePersonalInfo(data);
    }

    //修改密码
    @PostMapping("/personal/update/password/")
    public Map<String,String> updatePersonalPassword(@RequestBody Map<String,String> data){
       return personalService.updatePersonalPassword(data);
    }
}
